package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.CourSeorder;
import cn.wolfcode.crm.mapper.CourSeorderMapper;
import cn.wolfcode.crm.mapper.CustomerMapper;
import cn.wolfcode.crm.qo.CourSeorderQuery;
import cn.wolfcode.crm.service.ICourSeorderService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CourSeorderServiceimpl implements ICourSeorderService {

    @Autowired
    private CourSeorderMapper courSeorderMapper;
    @Autowired
    private CustomerMapper customerMapper;

    @Override
    public void save(CourSeorder courSeorder) {
        courSeorder.setInputTime(new Date());
        courSeorderMapper.insert(courSeorder);
        //修改客户状态
        customerMapper.updateStatus(1,courSeorder.getCustomer().getId());
    }

    @Override
    public void deleteByPrimaryKey(Long id) {

        courSeorderMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void updateByPrimaryKey(CourSeorder courSeorder) {

        courSeorderMapper.updateByPrimaryKey(courSeorder);

    }

    @Override
    public CourSeorder get(Long id) {
        return courSeorderMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<CourSeorder> selectAll() {
        return courSeorderMapper.selectAll();
    }

    @Override
    public PageInfo query(CourSeorderQuery qo) {

        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<CourSeorder> list = courSeorderMapper.queryForList(qo);
        return new PageInfo(list);

    }



}
